<template>
    <div class="good-item">
        <div v-for="(item, index) in GoodsData" :key="index">
            <div>
                <img v-preload=" item.img " alt />
                <img
                    @click="toDetail(item)"
                    src=""
                    alt
                />
            </div>
            <div class="font">{{item.title}}</div>
            <!-- <div class="tag" v-if="$route.meta.showGoodsTag">
                <div v-for="(prop, index) in item.props" :key="index">{{prop}}</div>
            </div>-->
            <div>
                <span>￥ {{item.price}}</span>
                <div>
                    <span>{{item.cfav}}</span>
                    <span class="iconfont icon-like"></span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        GoodsData: {
            type: Array,
            default() {
                return [];
            }
        }
    },
    methods: {
        toDetail(goodsData) {
            // 为模拟后台取数据 做的额外操作
            localStorage.setItem(
                goodsData.tradeItemId,
                JSON.stringify(goodsData)
            );
            this.$router.push({
                name: "detail",
                params: {
                    goodsId: goodsData.tradeItemId
                }
            });
        }
    }
};
</script>

<style lang="less" scoped>
.good-item {
    margin-top: 20px;
    &::after {
        content: "";
        display: block;
        clear: both;
    }
    > div {
        width: 50%;
        float: left;
        box-sizing: border-box;
        padding: 0 10px;
        margin-bottom: 20px;
        > div:nth-child(1) {
            text-align: center;
            position: relative;
            img:first-child {
                width: 100%;
                height: 532.8px;
                border-radius: 10px 10px 0 0;
                object-fit: contain;
            }
            img:last-child {
                width: 60px;
                height: 60px;
                position: absolute;
                right: 20px;
                bottom: 20px;
            }
        }
        .font {
            color: @font;
            font-size: 25px;
            text-indent: 50px;
            overflow: hidden;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
        }
        // .tag {
        //     padding: 0 20px;
        //     margin-bottom: 20px;
        //     height: 120px;
        //     overflow: hidden;
        //     &::after {
        //         content: "";
        //         display: block;
        //         clear: both;
        //     }
        //     > div {
        //         color: @font;
        //         float: left;
        //         width: 50px;
        //         height: 50px;
        //         background-color: rgb(179, 219, 216);
        //         font-size: 24px;
        //         text-align: center;
        //         line-height: 50px;
        //         border-radius: 10px;
        //         margin: 10px 10px 0 0;
        //         padding: 0 10px;
        //     }
        // }
        > div:nth-child(3) {
            display: flex;
            flex-flow: row nowrap;
            justify-content: space-between;
            > span {
                font-size: 32px;
                font-weight: bold;
            }
            > div {
                color: @99;
                span:first-child {
                    margin-right: 10px;
                    font-size: 27px;
                }
                span:last-child {
                    font-size: 25px;
                }
            }
        }
    }
}
</style>